﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class DancingWithTheGooglers
    {
        public DancingWithTheGooglers()
        {
            int testCount = Int32.Parse(TestConsole.ReadLine());
            for (int testCase = 1; testCase <= testCount; testCase++)
            {
                string[] input = TestConsole.ReadLine().Split(' ');
                int count = Int32.Parse(input[0]);
                int suprise = Int32.Parse(input[1]);
                int best = Int32.Parse(input[2]);
                int[] totals = new int[count];
                for (int i = 3; i < count + 3; i++)
                {
                    totals[i - 3] = Int32.Parse(input[i]);
                }
                int[] bestByNormal = new int[count];
                int[] bestBySuprise = new int[count];
                for (int i = 0; i < count; i++)
                {
                    if (totals[i] == 0) continue;
                    switch (totals[i] % 3)
                    {
                        case 0:
                            bestByNormal[i] = totals[i] / 3;
                            bestBySuprise[i] = (totals[i] + 3) / 3;
                            break;
                        case 1:
                            bestByNormal[i] = (totals[i] + 2) / 3;
                            bestBySuprise[i] = (totals[i] + 2) / 3;
                            break;
                        case 2:
                            bestByNormal[i] = (totals[i] + 1) / 3;
                            bestBySuprise[i] = (totals[i] + 4) / 3;
                            break;
                    }
                }
                int result = 0;
                while (suprise-- > 0)
                {
                    int step1 = -1, step2 = -1, step3 = -1;
                    for (int i = 0; i < count; i++)
                    {
                        if (step1 < 0 && bestByNormal[i] > 0 && bestByNormal[i] < best && bestBySuprise[i] >= best)
                        {
                            step1 = i;
                        }
                        else if (step2 < 0 && bestByNormal[i] > 0 && bestByNormal[i] >= best && bestBySuprise[i] >= best)
                        {
                            step2 = i;
                        }
                        else if (step3 < 0 && bestByNormal[i] > 0 && bestByNormal[i] >= best && bestBySuprise[i] < best)
                        {
                            step3 = i;
                        }
                    }
                    if (step1 >= 0)
                    {
                        bestByNormal[step1] = -1;
                    }
                    else if (step2 >= 0)
                    {
                        bestByNormal[step2] = -1;
                    }
                    else if (step3 >= 0)
                    {
                        bestByNormal[step3] = -2;
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    if (bestByNormal[i] >= best || bestByNormal[i] == -1)
                    {
                        result++;
                    }
                }
                Console.WriteLine("Case #" + testCase + ": " + result);
            }
        }
    }
}
